package cn.yanhu.kuwanapp.invite

import android.os.Bundle
import cn.woochen.comlib.BaseFragment
import cn.yanhu.kuwanapp.R
import cn.yanhu.kuwanapp.databinding.FragmentInviteBinding
import cn.yanhu.kuwanapp.home.MainViewModel
import cn.yanhu.kuwanapp.http.UrlConstainer
import cn.yanhu.kuwanapp.utils.helper.WebViewHelper

/**
 *
 * 类描述：邀请
 * @author：woochen
 * create at：2021/7/27 10:38 PM
 */
class InviteFragment : BaseFragment<FragmentInviteBinding, MainViewModel>() {

    override fun setContentView(): Int = R.layout.fragment_invite

    override fun initData() {
        showLoading(true)
        WebViewHelper.configSetting(mContext,mBinding.webView, {
            showContent()
        })
        requestData()
    }

    override fun requestData() {
        WebViewHelper.loadUrl(mBinding.webView,mUrl)
    }

    fun canBack(): Boolean {
        if (mBinding.webView.canGoBack()) {
            mBinding.webView.goBack()
            return true
        } else return false
    }

    private val mUrl by lazy {
        arguments?.getString(EXTRA_URL)?:""
    }

    fun refreshData() {
        requestData()
    }



    companion object {
        private const val EXTRA_URL = "extra_url"
        fun newInstance(url: String) = InviteFragment().apply {
            arguments = Bundle().apply {
                putString(EXTRA_URL, url)
            }
        }
    }
}